<template>
	<div class="main">
		<editor-ui @cancel="cancelEditor" @save="saveEditor" :html="val"></editor-ui>
	</div>
</template>

<script>
	import editorUi from '@/components/robin-editor/editor.vue'
	export default{
		name: 'editor',
		components:{editorUi},
		data(){
			return{
				mark: '',
				val: ''
			}
		},
		onLoad(e) {
			if(e.mark){
				this.mark = e.mark
			}
			if(e.val){
				this.val = e.val	
			}
		},
		methods:{
			//取消
			cancelEditor(){
				this.setText(false, '')
				uni.navigateBack({delta: 1})
			},
			//保存
			saveEditor(e){
				this.setText(true, e.html)
				uni.navigateBack({delta: 1})
			},
			// 上一页文本数据设定
			setText(dist, val){
				let pages = getCurrentPages();
				let prevPage = pages[pages.length - 2]; //上一个页面 
				prevPage.setData({
					mark: this.mark,
					dist: dist,	//true保存 false取消
				    select_data: val
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		
	}
</style>
